#!/usr/bin/python
# encoding: utf-8
import requests
import threading
from lxml import etree
import sys
import os
import datetime
import re
import random
import time
from xml.dom.minidom import parse
import xml.dom.minidom

reload(sys)

sys.setdefaultencoding('utf-8')



                # dic['name'].append([title,url])
def log(context):
    txtName = "./log/log.txt"
    f=file(txtName, "a+")
    # f.write("************************************************************")
    f.writelines(context+"\n") 
    # f.write("************************************************************")
    f.close()



def xin():
            header = {
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36',
                'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
                'Accept-Encoding': 'gzip, deflate, br',
                'Accept-Language': 'zh-CN,zh;q=0.9'
            }
            



           
        
            last=[]
            abc = ['q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m']
            for index1 in range(len(abc)):
                 for index2 in range(len(abc)):
                    shu=abc[index1]+abc[index2]+".cn"
                    # print(shu)
                    last.append(shu)
            # for index3 in range(len(abc)):
                # for index4 in range(len(abc)):

            for index in range(len(last)):
                url="http://panda.www.net.cn/cgi-bin/check.cgi?area_domain="+last[index];
                response=requests.get(url,headers=header)
                html=response.content.decode("utf8")
                print(html)

            
                log(str(index)+"================="+url)
          
                txtName = "./file/test.xml"
                f=file(txtName, "a+")
                f.write(html)
                f.close()

                sui=random.randint(5,10)
                # print("休眠"+str(sui))
                log("休眠"+str(sui))
                time.sleep(sui)
            

if __name__=="__main__":
    xin()
    


    